﻿//设置footer菜单高亮索引0开始
function mainTabar(index) {
    $(".weui_tabbar_item").removeClass("weui_bar_item_on");
    $(".weui_tabbar_item").eq(index).addClass("weui_bar_item_on");

    var tabImg = $(".weui_tabbar").find(".weui_tabbar_icon");
    //tabImg.removeClass("iconGray");
    //tabImg[i].className = tabImg[i].className + " iconGray";

    tabImg.each(function (d, ds) {
        if (d != index) {
            ds.className == "weui_tabbar_icon iconGray";
        } else {
            ds.className = "weui_tabbar_icon";
        }
    });
}


//验证是否为空
function isEmptyValue(value) {
    if (value == undefined || value == "") {
        return true;
    }
    return false;
}

//验证码倒计时
var wait = 60;

function aSendSMS(SMSType, uPhone) {
    if (wait != 60) {
        return;
    }
    sendSMS("/Me/SendUserSMS", uPhone, SMSType,
        function (suc) {
            $.alert("短信发送成功");
            time($("#aSendSMS"));
        },
        function (err) {
            $.alert(err.message);
        });
}

function time(o) {
    var cname = "f-red";
    if (wait == 0) {
        o.removeClass(cname);
        o.text("重新获取");
        wait = 60;
    } else {
        o.addClass(cname);

        o.text(wait + "秒重发");
        wait--;
        setTimeout(function () {
            time(o)
        },
        1000)
    }
}

//发送短信
function sendSMS(url, phone, SMSType, fnSuc, fnErr) {
    if (phone.length != 11) {
        $.alert("请正确填写手机号码");
        return;
    }
    $.get(url, { "phone": phone, "sType": SMSType }, function (d) {
        var data = $.parseJSON(htmlDecode(d));
        //发送成功
        if (data.statusCode == 200) {
            fnSuc(data);
        } else {
            fnErr(data);
        }
    });
}
